import http from '@/utils/http'
import { useAuthStore } from '@/store/auth'
import { storeToRefs } from 'pinia'

const authStore = useAuthStore()
const { globalParams, historyParams } = storeToRefs(authStore)
// 获取传感器列表
export const getSensorList = (params: any) => {
  if (globalParams.value.startTime) {
    return http.postOrJson('/monitor/his/dataList', { ...globalParams.value, ...params })
  }
  return http.postOrJson('/monitor/sensorList', { ...globalParams.value, ...params })
}

// 获取历史曲线
export const getHisGraph = (params: any) => {
  return http.postOrJson('/monitor/getHisGraph', { ...globalParams.value, ...params })
}

// 获取实时曲线
export const getHistoryRealTimePushCurve = (params: any) => {
  return http.postOrJson('/monitor/getHistoryRealTimePushCurve', { ...globalParams.value, ...params })
}

// 获取传感器字典
export const getSensorDict = (sensorTypes: string[]) => {
  return http.postOrJson('/monitor/sensorDict', { ...globalParams.value, sensorTypes: sensorTypes.join(',') })
}

// 获取点位传感器列表
export const getAnnotationSensorList = (id: string) => {
  return http.get('/tunnel/getAnnotationSensorList', { params: { ...globalParams.value, ...historyParams.value, id } })
}

export const getKdSensorStatistic = () => {
  return http.get('/monitor/kdSensorStatistic', { params: { ...globalParams.value } })
}

export const getSensorHisValue = (params: any) => {
  return http.get('/monitor/getSensorHisValue', { params })
}